Question: 1 -
Which other keywords are also used to declare the class other than class?
-
Union
-
Struct
-
Object
-
Both struct & union
Answer:
Both struct & union
Solution:
Struct and union take the same definition of class but differs in the access techniques.
Struct and union take the same definition of class but differs in the access techniques.
Question: 2 -
Which of the following is not correct for virtual function in C++ ?
-
Virtual function is defined in base class
-
Virtual function should be accessed using pointers
-
Virtual function can be static.
-
Must be declared in public section of class
Answer:
Virtual function can be static.
Solution:
Virtual function is can’t be static in C++.
Virtual function is can’t be static in C++.
Question: 3 -
How can we make a class abstract?
-
By declaring it abstract using the virtual keyword.
-
By making all member functions constant
-
By declaring it abstract using the static keyword.
-
By making at least one member function as pure virtual function.
Answer:
By making at least one member function as pure virtual function.
Solution:
We can make a class abstract by making at least one member function as pure virtual function.
We can make a class abstract by making at least one member function as pure virtual function.
Question: 4 -
Which of these following members are not accessed by using direct member access operator?
-
Protected
-
Private
-
Public
-
Both B & C
Answer:
Both B & C
Solution:
Because of the access is given to the private and protected, We can’t access them by using direct member access operator.
Because of the access is given to the private and protected, We can’t access them by using direct member access operator.
Question: 5 -
How many specifiers are present in access specifiers in class?
-
4
-
2
-
1
-
3
Answer:
3
Solution:
There are three types of access specifiers. They are public, protected and private.
There are three types of access specifiers. They are public, protected and private.